@import './abstracts/variable';
@import './abstracts/mixin';
@import './icon.scss';

@include b(checkbox) {
  display: block;
  margin-bottom: $-checkbox-margin;
  font-size: 0;
  -webkit-tap-highlight-color: transparent;

  &:last-child {
    margin-bottom: 0;
  }

  @include e(shape) {
    position: relative;
    display: inline-block;
    width: $-checkbox-size;
    height: $-checkbox-size;
    border: 1px solid $-checkbox-border-color;
    border-radius: 50%;
    color: #fff;
    background: #fff;
    vertical-align: middle;
    transition: background .2s;

    @include when(square) {
      border-radius: $-checkbox-square-radius;
    }
  }
  @include e(input) {
    position: absolute;
    width: 0;
    height: 0;
    margin: 0;
    opacity: 0;
  }
  @include e(btn-check) {
    position: absolute;
    display: inline-block;
    left: 16px;
    top: 50%;
    font-size: 16px;
    transform: translateY(-50%);
    margin-right: 4px;
    height: 16px;
    width: 16px;
  }
  @include e(txt) {
    display: inline-block;
    vertical-align: middle;
    line-height: 1.43;
  }
  @include e(label) {
    position: relative;
    display: inline-block;
    margin-left: $-checkbox-label-margin;
    vertical-align: top;
    font-size: $-checkbox-label-fs;
    color: $-checkbox-label-color;
  }
  @include e(check) {
    position: absolute;
    display: inline-block;
    right: 0;
    top: 1px;
    color: #fff;
    font-size: 13px;
    opacity: 0;
    transition: opacity .2s;
  }
  @include when(checked) {
    .wd-checkbox__shape {
      color: $-checkbox-checked-color;
      background: currentColor;
      border-color: currentColor;
    }
    .wd-checkbox__check {
      opacity: 1;
    }
  }

  @include when(button) {
    display: inline-block;
    margin-bottom: 0;
    margin-right: $-checkbox-margin;
    vertical-align: top;

    &:last-child {
      margin-right: 0;
    }
    .wd-checkbox__shape {
      width: 0;
      height: 0;
      overflow: hidden;
      opacity: 0;
      border: none;
    }
    .wd-checkbox__label {
      margin-left: 0;
      padding: 4px 28px;
      border: 1px solid $-checkbox-border-color;
      border-radius: $-checkbox-button-radius;
      transition: color .2s, border .2s;
    }
    @include when(checked) {
      .wd-checkbox__label {
        padding-left: 40px;
        padding-right: 16px;
        color: $-checkbox-checked-color;
        border-color: currentColor;
      }
    }
  }

  @include when(inline) {
    display: inline-block;
    margin-bottom: 0;
    margin-right: $-checkbox-margin;
    
    &:last-child {
      margin-right: 0;
    }
  }

  @include when(disabled) {
    .wd-checkbox__shape {
      border-color: $-checkbox-disabled-label-color;
    }
    .wd-checkbox__label {
      color: $-checkbox-disabled-label-color;
    }
    @include when(checked) {
      .wd-checkbox__shape {
        color: $-checkbox-disabled-label-color;
      }
      .wd-checkbox__label {
        color: $-checkbox-disabled-label-color;
      }
    }
    @include when(button) {
      .wd-checkbox__label {
        border-color: $-checkbox-disabled-color;
      }
    }
  }
}